/*******************************************************************************
 *  OptionElement class
 *******************************************************************************

// example options object
var options = {
    value: value,
    selected: selected,
    text: text
}

*/


/**
 *  Represent option model
 */
var OptionElement = function(options) {
    
    // this class should extend an Element class
    $.extend(true, this, new Element($('<option>')))
    this.getElement()[0].wrapper = this;
    // ------------------------------------------------------- settings
    this.defaults = {
        selected: false
    };
    
    var settings = this.prepareSettings(options);
    
    // ------------------------------------------------------- methods
    
    /**
     *  Sets value
     *  @param value
     *  @return class instance
     */
    this.setValue = function(value){
        this.getElement().val(value);
        return this;
    }
    
    // ------------------------------------------------------- element creation
    this.addAttribute('selected', settings.selected)
        .setText(settings.text)
        .setValue(settings.value);
        
    console.log('OptionElement was created with value = '+settings.value);
}


var EmptyOption = function(selected){
    return new OptionElement({
        value: '',
        selected: selected,
        text: ''
    })
}